﻿using System;
using System.Windows;
using WickedFlame.Core.Shapes;

namespace WickedFlame.Core.State
{
    [Serializable]
    internal class CurveMemento : ShapeMemento
    {
        Point _startPoint;
        Point _endPoint;
        Point _curvePoint;

        public override void SaveProperties(VectorShape shape)
        {
            base.SaveProperties(shape);

            CurveShape c = shape as CurveShape;
            if (c != null)
            {
                _startPoint = c.StartPoint;
                _endPoint = c.EndPoint;
                _curvePoint = c.CurvePoint;
            }
        }

        public override void ResetProperties(VectorShape shape)
        {
            base.ResetProperties(shape);

            CurveShape c = shape as CurveShape;
            if (c != null)
            {
                c.StartPoint = _startPoint;
                c.EndPoint = _endPoint;
                c.CurvePoint = _curvePoint;
            }
        }

        public override VectorShape GenerateShape()
        {
            var shape = new CurveShape();
            shape.ResetState(this);

            return shape;
        }
    }
}
